import 'package:flutterlib/common/net/retrofit/post_api.dart';
import 'package:flutterlib/model/interest/interest_bean.dart';
import 'package:flutterlib/model/post/comment_bean.dart';
import 'package:flutterlib/model/post/comment_request.dart';
import 'package:flutterlib/model/post/post_bean_page.dart';
import 'package:flutterlib/model/post/post_detail_bean.dart';
import 'package:mobx/mobx.dart';
part 'post_store.g.dart';

class PostStore = _PostStore with _$PostStore;

abstract class _PostStore with Store {


  @observable
  Observable<int> postTabIndex;

  @action
  changePostTabIndex(int index) => postTabIndex =
      Observable(index);

  @observable
  ObservableFuture<PostDetailBean> postDetailFuture;

  @action
  Future fetchPostDetail(int id) => postDetailFuture =
      ObservableFuture(PostApi.builder().getPost(id));

  @observable
  String searchWord;

  @action
  updateSearchWord(str) => searchWord = str;

  @observable
  ObservableFuture<CommentBean> commentFuture;

  @action
  Future writeComment(CommentRequest request) => commentFuture
      = ObservableFuture(PostApi.builder().comments(request));


  @observable
  ObservableFuture<PostBeanPage> cardPageFuture;

  @action
  Future fetchCards(int page, int size, String order, int interestId) => cardPageFuture =
      ObservableFuture(PostApi.builder().pageByQuerySheet(page, size, order, interestId));
}
